Skip to content

Fix terminal total difficulty gauge overflow - #93

Open
damilolaedwards wants to merge 1 commit into
ethpandaops:masterfrom
damilolaedwards:fix/ttd-gauge-overflow
Open

Fix terminal total difficulty gauge overflow#93
damilolaedwards wants to merge 1 commit into
ethpandaops:masterfrom
damilolaedwards:fix/ttd-gauge-overflow

Conversation

@damilolaedwards

Copy link
Copy Markdown

Summary

The gauge converted TerminalTotalDifficulty with big.Int.Uint64, which the standard library documents as undefined when the value doesn't fit in 64 bits. Mainnet's TTD doesn't fit, so the exported beacon_spec_terminal_total_difficulty metric silently reported a meaningless number on mainnet.

Fix goes through big.Float first, the same way the adjacent trillions gauge already does (that gauge only exists because someone hit this same overflow and worked around it there without fixing the raw one).

Test plan

  • Added TestObserveSpec_TerminalTotalDifficulty in pkg/beacon/metrics_spec_test.go, feeding mainnet's real TTD through observeSpec and reading the gauge back
  • Confirmed the test fails against the old uint64 conversion and passes against the fix
  • go build ./..., go vet ./..., go test -race ./... all green

The gauge converted TerminalTotalDifficulty with big.Int.Uint64,
which the standard library documents as undefined when the value
doesn't fit in 64 bits. Mainnet's TTD doesn't fit, so the exported
metric silently reported a meaningless number. It now goes through
big.Float first, the same way the adjacent trillions gauge already
does.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant